<style type="text/css">
#apDiv1 {
	position: absolute;
	left: 353px;
	top: 830px;
	width: 207px;
	height: 24px;
	z-index: 1;
}
#apDiv2 {
	position: absolute;
	left: 66px;
	top: 272px;
	width: 114px;
	height: 24px;
	z-index: 1;
}
</style>
<?php $this->beginWidget('application.widget.site.bannerWidget'); ?>
<?php $this->endWidget(); ?>
<div id="contener" _height="auto">
	<div class="left_menu">
		<?php $this->beginWidget('application.widget.site.leftWidget'); ?>
		<?php $this->endWidget(); ?>
		<?php $this->beginWidget('application.widget.site.faceWidget'); ?>
		<?php $this->endWidget(); ?>
	</div>
	<div class="main">
		<?php $this->beginWidget('application.widget.site.newWidget'); ?>
		<?php $this->endWidget(); ?>
		<div class="right_mainBox">
			<div class="right_mainBox_top"></div>
			<div class="mainMenu"> <img src="images/<?=$classArr['image']?>" alt="人氣限定" width="726" height="40" border="0" usemap="#Map" />
				<map name="Map" id="Map">
					<area shape="rect" coords="22,3,156,36" href="<?=Yii::app()->createUrl('activity/index',array('class'=>'人氣限定'))?>" target="_self" alt="人氣限定" title="人氣限定" />
					<area shape="rect" coords="158,3,292,36" href="<?=Yii::app()->createUrl('activity/index',array('class'=>'時間限定'))?>" target="_self" alt="時間限定" title="時間限定" />
					<area shape="rect" coords="294,4,426,35" href="<?=Yii::app()->createUrl('activity/index',array('class'=>'贊助限定'))?>" target="_self" alt="贊助限定" title="贊助限定" />
					<area shape="rect" coords="430,1,564,37" href="<?=Yii::app()->createUrl('activity/closed')?>" target="_self" alt="已結束" title="已結束" />
				</map>
			</div>
			<div class="mainContentBox">
				<?php
			if($rowset){
				$timeArr = array();
				foreach($rowset as $rowTable){
			?>
				<table width="726" border="0" cellpadding="0" cellspacing="0" id="table2">
					<tr>
						<?php
					for($i=0;$i<3;$i++){
						$row = $rowTable[$i];
						if($row){
							if($row->status==1){
								$timeArr[$row['serial']] = strtotime($row->starttime)-time();
					?>
						<td width="242">
							<div class="pd_box">
								<div class="pd_boxName"><?=$row['activityname']?></div>
								<div class="pd_boxImgBlack"><span></span><span id="lock_<?=$row->serial?>"></span><img src="<?=Yii::app()->params['prizePath']?>/<?=$row->prize->pic?>" alt="<?=$row->prize->prizename?>" title="<?=$row->prize->prizename?>" width="320" height="240" border="0" /></div>
								<div class="pd_boxText"> <span class="clock" id="time_<?=$row->serial?>"></span> </div>
							</div>
						</td>
						<?php
							}elseif($row->status==2 || $row->status==3){
					?>
						<td width="242"> <a href="<?=Yii::app()->createUrl('activity/detail',array('id'=>$row->activityid))?>">
							<div class="pd_box">
								<div class="pd_boxName"><?=$row['activityname']?></div>
								<div class="pd_boxImg"><img src="<?=Yii::app()->params['prizePath']?>/<?=$row->prize->pic?>" alt="<?=$row->prize->prizename?>" title="<?=$row->prize->prizename?>" width="320" height="240" border="0" /></div>
								<div class="pd_boxText"> <span class="count">
									<?=count($row->records)?>
									/
									<?=$row->people?>
									</span> </div>
							</div>
							</a> </td>
						<?php
							}else{
								$timeArr[$row['serial']] = strtotime($row->endtime)+$row->delaytime-time();
					?>
						<td width="242"> <a href="<?=Yii::app()->createUrl('activity/detail',array('id'=>$row->activityid))?>">
							<div class="pd_box">
								<div class="pd_boxName"><?=$row['activityname']?></div>
								<div class="pd_boxImg"><img src="<?=Yii::app()->params['prizePath']?>/<?=$row->prize->pic?>" alt="<?=$row->prize->prizename?>" title="<?=$row->prize->prizename?>" width="320" height="240" border="0" /></div>
								<div class="pd_boxText"> <span class="clock" id="time_<?=$row->serial?>"></span> <span class="count">
									<?=count($row->records)?>
									/
									<?=$row->people?>
									</span> </div>
							</div>
							</a> </td>
						<?php
							}
						}else{
					?>
						<td width="242">&nbsp;</td>
						<?php
						}
					}
					?>
					</tr>
				</table>
				<?php
				}
			}else{
			?>
				<table border="0" width="726" cellspacing="0" cellpadding="0" id="table3">
					<tbody>
						<tr>
							<td class="newword">&nbsp;</td>
						</tr>
					</tbody>
				</table>
				<?php
			}
			?>
				<div id="pager" align="center">
					<?php  
					$this->widget('CLinkPager',array(  
						'header'=>'',  
						'firstPageLabel' => '<<',
						'lastPageLabel' => '>>',
						'prevPageLabel' => '<',
						'nextPageLabel' => '>',
						'pages' => $pages,  
						'maxButtonCount'=>13  
						));  
				?>
				</div>
			</div>
			<div class="right_mainBox_bottom"></div>
		</div>
	</div>
</div>
<script>
$(document).ready(function() {
<?php
if($timeArr){
?>
RF = new Object();
<?php
	foreach($timeArr as $tKey=>$tValue){
?>
RF['<?=$tKey?>'] = '<?=$tValue?>';
<?php
	}
?>
for ($f in RF) {
	if ($f == null) { 
		continue;
	}
	onTimer($f,RF[$f],changeShowTime,onTimeEnd);
}
<?php
}
?>
});
 
// 该函数用于显示倒计时
function changeShowTime(id,time) {
    /* 该函数内编写显示倒计时的语句 */  
    $(id).html(time);    
}
//倒計時結束的時候執行的函數
function onTimeEnd(id){
	$.post('<?php echo CHtml::normalizeUrl(array('/activity/opration'));?>',{'serial':id}, function (data) {
		var ret = $.parseJSON(data);
		location.reload(true);
	});
}
</script>